Left-leaning Red-Black Trees
نویسنده
چکیده
The red-black tree model for implementing balanced search trees, introduced by Guibas and Sedgewick thirty years ago, is now found throughout our computational infrastructure. Red-black trees are described in standard textbooks and are the underlying data structure for symbol-table implementations within C++, Java, Python, BSD Unix, and many other modern systems. However, many of these implementations have sacrificed some of the original design goals (primarily in order to develop an effective implementation of the delete operation, which was incompletely specified in the original paper), so a new look is worthwhile. In this paper, we describe a new variant of redblack trees that meets many of the original design goals and leads to substantially simpler code for insert/delete, less than one-fourth as much code as in implementations in common use. All red-black trees are based on implementing 2-3 or 2-3-4 trees within a binary tree, using red links to bind together internal nodes into 3-nodes or 4-nodes. The new code is based on combining three ideas: Use a recursive implementation. • Require that all 3-nodes lean left. • Perform rotations on the way up the tree (after the recursive calls). • Not only do these ideas lead to simple code, but they also unify the algorithms: for example, the leftleaning versions of 2-3 trees and top-down 2-3-4 trees differ in the position of one line of code. All of the red-black tree algorithms that have been proposed are characterized by a worst-case search time bounded by a small constant multiple of lg N in a tree of N keys, and the behavior observed in practice is typically that same multiple faster than the worst-case bound, close the to optimal lg N nodes examined that would be observed in a perfectly balanced tree. This performance is also conjectured (but not yet proved) for trees built from random keys, for all the major variants of red-black trees. Can we analyze average-case performance with random keys for this new, simpler version? This paper describes experimental results that shed light on the fascinating dynamic behavior of the growth of these trees. Specifically, in a left-leaning red-black 2-3 tree built from N random keys: A random successful search examines lg • N – 0.5 nodes. The average tree height is about 2 ln • N (!) The average size of left subtree exhibits log-oscillating behavior. • The development of a mathematical model explaining this behavior for random keys remains one of the outstanding problems in the analysis of algorithms. From a practical standpoint, left-leaning red-black trees (LLRB trees) have a number of attractive characteristics: Experimental studies have not been able to distinguish these algorithms from optimal. • They can be implemented by adding just a few lines of code to standard BST algorithms. • Unlike hashing, they support ordered operations such as • select, rank, and range search. Thus, LLRB trees are useful for a broad variety of symbol-table applications and are prime candidates to serve as the basis for symbol tables in software libraries in the future.
منابع مشابه
Constructing Red-Black Trees
This paper explores the structure of red-black trees by solving an apparently simple problem: given an ascending sequence of elements, construct, in linear time, a red-black tree that contains the elements in symmetric order. Several extreme red-black tree shapes are characterized: trees of minimum and maximum height, trees with a minimal and with a maximal proportion of red nodes. These charac...
متن کاملConcurrent Rebalancing on HyperRed-Black Trees
The HyperRed-Black trees are a relaxed version of RedBlack trees accepting high degree of concurrency. In the Red-Black trees consecutive red nodes are forbidden. This restriction has been withdrawn in the Chromatic trees. They have been introduced by O. Nurmi and E. Soisalon-Soininen to work in a concurrent environment. A Chromatic tree can have big clusters of red nodes surrounded by black no...
متن کاملGeneric Red-Black Tree and its C# Implementation
The focus of this installment of the Educator's Corner is on tree construction – red-black trees. Some of the material for this column is taken from Chapter 13 of the forthcoming book " Modern Software Development Using C#/.NET " by Richard Wiener. This book will be published by Thomson, Course Technology in the Fall, 2005. A fascinating and important balanced binary search tree is the red-blac...
متن کاملA appraisal paper on Breadth-first search, Depth-first search and Red black tree
Breadth-first and depth-first search are indispensable adventure strategies leading which many other rummage around algorithms are built. In this dissertation, we projected an loomed of integrating these two strategies in a solitary algorithm that combines the corresponding strengths of mutual. We account preliminary computational outcome using the tree width predicament as an example. This dis...
متن کاملThe Performance of Concurrent Red-Black Tree Algorithms
Relaxed balancing has become a commonly used concept in the design of concurrent search tree algorithms. The idea of relaxed balancing is to uncouple the rebalancing from the updating in order to speed up the update operations and to allow a high degree of concurrency. Many di erent relaxed balancing algorithms have been proposed, especially for red-black trees and AVL trees, but their performa...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2008